package com.zjj.learn.designmodel.pattern.singleton.demo8;


import java.lang.reflect.Constructor;

/** 测试通过反射破坏单例模式
 * *** @author zjj_admin
 * *** 2022/4/5 16:43
 */
public class ClientTest8 {

    public static void main(String[] args) throws Exception {
        Class clazz = Singleton.class;

        Constructor constructor = clazz.getDeclaredConstructor();
        constructor.setAccessible(true);

        Singleton instance1 = (Singleton) constructor.newInstance();
        Singleton instance2 = (Singleton) constructor.newInstance();
        System.out.println(instance2 == instance1);
    }




}
